﻿<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/Administrator/Admin.master" CodeFile="polls.aspx.cs" Inherits="Administrator_polls" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div style="width:95%; padding-left:20px" >
    <asp:SqlDataSource ID="PollDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:up1vnConnectionString %>"
        SelectCommand="SELECT * FROM [Polls]" DeleteCommand="DELETE FROM Polls WHERE PollID = @PollID" InsertCommand="INSERT INTO Polls (DisplayText,active,sl) VALUES (@DisplayText,@active,@sl)">
        <DeleteParameters>
            <asp:Parameter Name="PollID" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="DisplayText" />
        </InsertParameters>
         <InsertParameters>
            <asp:Parameter Name="active" />
        </InsertParameters>
         <InsertParameters>
            <asp:Parameter Name="sl" />
        </InsertParameters>
    </asp:SqlDataSource>

    <p>
        <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" DataKeyNames="PollID"
            DataSourceID="PollDataSource" DefaultMode="Insert" CellPadding="4" ForeColor="#333333" GridLines="None">
            <Fields>
                <asp:BoundField DataField="PollID" HeaderText="PollID" InsertVisible="False" ReadOnly="True"
                    SortExpression="PollID" />                
                <asp:TemplateField HeaderText="Câu h&#7887;i Poll : ">
                    <InsertItemTemplate>
                        <asp:TextBox ID="NewPollQuestion" runat="server" Columns="75" Text='<%# Bind("DisplayText") %>'></asp:TextBox>

                        <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="NewPollQuestion"
                            ErrorMessage="B&#7841;n ph&#7843;i nh&#7853;p v&#259;n b&#7843;n cho câu h&#7887;i bình ch&#7885;n" Display="Dynamic"></asp:RequiredFieldValidator>
                    </InsertItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Active : ">
                    <InsertItemTemplate>   <asp:CheckBox ID="CheckPollQuestion" runat="server"   Checked='<%# Bind("active") %>' />
                    </InsertItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="S&#7889; L&#432;&#7907;ng tham gia : ">
                    <InsertItemTemplate>  <asp:TextBox ID="soluong"  runat="server" Columns="3" Text='<%# Bind("sl") %>'></asp:TextBox>
                    </InsertItemTemplate>
                </asp:TemplateField>
                <asp:CommandField ShowCancelButton="False" ShowInsertButton="True" InsertText="Thêm câu h&#7887;i Poll m&#7899;i" />
            </Fields>
            <FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
            <CommandRowStyle BackColor="#FFFFC0" Font-Bold="True" />
            <RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
            <PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
            <FieldHeaderStyle BackColor="#FFFF99" Font-Bold="True" />
            <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
            <AlternatingRowStyle BackColor="White" />
        </asp:DetailsView>
    </p>
    <p>
        <asp:GridView ID="PollGridView" runat="server" AutoGenerateColumns="False" DataKeyNames="PollID"
            DataSourceID="PollDataSource" CellPadding="4" ForeColor="#333333" GridLines="None">
            <Columns>
                <asp:HyperLinkField DataNavigateUrlFields="PollID" DataNavigateUrlFormatString="quanlycauhoipoll.aspx?pid={0}"
                    Text="S&#7917;a" />
                <asp:TemplateField ShowHeader="False">
                    <ItemTemplate>
                        <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Delete"
                            OnClientClick="return confirm('This will permanently delete this poll and all of its results. Are you sure you want to do this?');"
                            Text="Xóa"></asp:LinkButton>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="PollID" HeaderText="Poll ID" InsertVisible="False" ReadOnly="True"
                    SortExpression="PollID" >
                    <ItemStyle HorizontalAlign="Center" />
                </asp:BoundField>
                <asp:TemplateField HeaderText="Câu h&#7887;i Poll" SortExpression="DisplayText">
                    <EditItemTemplate>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="pollQuestion"
                            ErrorMessage="You must enter text for the poll question"></asp:RequiredFieldValidator>
                        <asp:TextBox ID="pollQuestion" runat="server" Columns="75" Text='<%# Bind("DisplayText") %>'></asp:TextBox>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="Label1" runat="server" Text='<%# Bind("DisplayText") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Active" SortExpression="DisplayText">                   
                    <ItemTemplate>
                         <asp:CheckBox ID="CheckPoll" runat="server"  />
                    </ItemTemplate>
                </asp:TemplateField>
                 <asp:TemplateField HeaderText="SL tham gia" SortExpression="DisplayText">                   
                    <ItemTemplate>
                           <asp:Label ID="Labelhb" runat="server" Text='<%# Bind("sl") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:HyperLinkField DataNavigateUrlFields="PollID" DataNavigateUrlFormatString="viewpolls.aspx?pid={0}"
                    Text="Xem bình ch&#7885;n" />
            </Columns>
            <FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
            <RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
            <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
            <PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
            <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
            <AlternatingRowStyle BackColor="White" />
        </asp:GridView>
    </p></div>
</asp:Content>